package org.example;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class TextSet {

    public static void deomHashSet(){
        //set打印与添加顺序不一致，元素重复自动过滤
        Set<String> set = new HashSet<>();
        set.add("抛出");
        set.add("领导");
        set.add("上课");
        set.add("到了");
        System.out.println(set);
        //遍历set对象
        Iterator<String> is =set.iterator();//返回迭代器对象
        while (is.hasNext()){ //判断是否有下一个元素
            System.out.println(is.next());
        }

    }

    public static void main(String[] args) {
        deomHashSet();
    }

}
